package com.poorstu.web;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.DynaActionForm;

import com.common.base.web.BaseAction;
import com.poorstu.manager.PartTimeManager;
import com.poorstu.model.PartTimeMod;

public class PartTimeChangeAction extends BaseAction {

	@Override
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		
		try {
		DynaActionForm dyna=(DynaActionForm)form;
		int jobId=(Integer)dyna.get("jobId");
		String company=(String)dyna.get("company");
		int money=(Integer)dyna.get("salary");
		String contactName=(String)dyna.get("contactName");
		String conPhone=(String)dyna.get("contactPhone");
		String emile=(String)dyna.get("contactEmail");
		int peopleNum=(Integer)dyna.get("number");
		String content=(String)dyna.get("content");
		String status=(String)dyna.get("status");
		String startTime=(String)dyna.get("starTime");
		String  endTime=(String)dyna.get("endTime");
		String other=(String)dyna.get("other");
		
		 SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
		 Date start =format.parse(startTime);
	     Date end = format.parse(endTime);
		
		PartTimeManager partTime=(PartTimeManager)getBean("partTimeManager");
		PartTimeMod part=partTime.selectPartTimeById(jobId);
		part.setCompany(company);
		part.setConPhone(conPhone);
		part.setContactName(contactName);
		part.setContent(content);
		part.setEmile(emile);
		part.setEndTime(end);
		part.setMoney(money);
		part.setPeopleNum(peopleNum);
		part.setStartTime(start);
		part.setStatus(status);
		part.setOther(other);
		
		partTime.changePartTime(part);
		
		return mapping.findForward("succ");
	} catch (ParseException e) {
		e.printStackTrace();
		return mapping.findForward("failure");
		
	}
	}
	
	

}
